package com.hua.fanqiemall.product.service.impl;

import com.hua.fanqiemall.product.vo.AttrGroupRelationReqVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hua.common.utils.PageUtils;
import com.hua.common.utils.Query;

import com.hua.fanqiemall.product.dao.AttrAttrgroupRelationDao;
import com.hua.fanqiemall.product.entity.AttrAttrgroupRelationEntity;
import com.hua.fanqiemall.product.service.AttrAttrgroupRelationService;


@Service("attrAttrgroupRelationService")
public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationDao, AttrAttrgroupRelationEntity> implements AttrAttrgroupRelationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrAttrgroupRelationEntity> page = this.page(
                new Query<AttrAttrgroupRelationEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    /**
     * 批量保存关联关系
     * @author luoweihua
     * @date 2022/1/11 21:48
     * @param reqVoList 入参
     */
    @Override
    public void saveBatch(List<AttrGroupRelationReqVo> reqVoList) {
        List<AttrAttrgroupRelationEntity> relationEntityList = new ArrayList<>();
        for (AttrGroupRelationReqVo relationReqVo : reqVoList) {
            AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
            BeanUtils.copyProperties(relationReqVo,relationEntity);
            relationEntityList.add(relationEntity);
        }
        this.saveBatch(relationEntityList);
    }

}